package entidades;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Claudia
 */
public class validaRut  {
 
    public String rut;

    public validaRut() {
    }
   
     public boolean validaRUT(String rut)
    {
        String [] aux = rut.split("-");
        if (aux[0].equals("")) return false;
          int M = 0, S = 1, T = Integer.parseInt(aux[0]);
          for (; T != 0; T /= 10)
             {
                 S = (S + T % 10 * (9 - M++ % 6)) % 11;
             }
         char kaka =  ((char) (S != 0 ? S + 47 : 75));


          if(aux[1].charAt(0)== kaka)
          {
              return true;
          }
          else
          {
              return false;
          }
    }
}
